using System;
using System.Collections.Generic;
using System.Text;

namespace TTDotNet.Engine.Networks
{
    public class SortedNodeList
    {
        List<AStarNode> list;

        public SortedNodeList()
        {
            list = new List<AStarNode>();
        }

        public void AddNode(AStarNode node)
        {
            for (int i = 0; i < list.Count; i++)
            {
                if (node.CompareTo(list[i]) < 0)
                {
                    list.Insert(i, node);
                    return;
                }
            }

            list.Add(node);
        }

        public void RemoveNode(AStarNode node)
        {
            list.Remove(node);
        }

        public AStarNode Fetch(AStarNode node)
        {
            return list[list.IndexOf(node)];
        }

        public int IndexOf(AStarNode node)
        {
            return list.IndexOf(node);
        }

        public bool Contains(AStarNode node)
        {
            return list.Contains(node);
        }

        public AStarNode Pop()
        {
            AStarNode temp = list[0];
            list.RemoveAt(0);
            return temp;
        }

        public int Size()
        {
            return list.Count;
        }

    }
}
